﻿@using ClinicaDentalApp.Models.Base
@model IEnumerable<TomaDeHora>

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "TomaDeHoras";
}

@section scripts{
    <script language="javascript" type="text/javascript">
        $(function () {
            $("#fechaFiltro").datepicker({
                dateFormat: "dd/mm/yy",
                yearRange: "-90,-1",
                changeMonth: true,
                changeYear: true,
                showOn: "button",
			    buttonImage:  "@Url.Content("~/Content/imagenes/lupa.png")",
			    buttonImageOnly: true,
                onSelect: function () {
                    $(this).change();
                }
            });

            $("#fechaFiltro").change(function () {
                $("#formFiltro").submit();
            });
            $("#FiltroPersonas").autocomplete({
                source: '@(Url.Action("AutocompleteTomaHoras"))',
                minLength: 3,
                select: function (event, ui) {
                    window.location = '@Url.Action("TomaDeHorasSingle")?id=' + ui.item.id;
                }
            });
        });
    </script>
}

<h2>Toma De Horas</h2>
@using (Html.BeginForm("TomadeHoras", "Pacientes", FormMethod.Post, new { @id = "formFiltro" }))
{
    <div>Seleccionar Fecha:
        <div style="width: 10%">@Html.TextBox("FechaHora", "", new { @id = "fechaFiltro" })</div>
    </div>
}
Filtrar por persona:
@Html.TextBox("FiltroPersona", "", new { @id = "FiltroPersonas" })
<br />

<div>
<br />
    <table style="width:100%; margin-left:auto; margin-right:auto; text-align:center;">
        <thead>
            <tr style="text-align:center;">
                <th>Hora</th>
                <th>Nombre</th>
                <th>apellidos</th>
                <th>RUT</th>
                <th>Motivo Consulta</th>
                <th></th>
            </tr>
        </thead>
            @foreach (TomaDeHora hora in Model)
            {
                <tr>
                    <td>@hora.FechaHoraAtencion</td>
                    <td>@hora.Nombre</td>
                    <td>@hora.ApellidoPaterno @hora.ApellidoMaterno</td>
                    <td>@hora.Rut</td>
                    <td>@hora.MotivoConsulta</td>
                    <td>
                        <div class="Boton">@Html.ActionLink("Eliminar", "eliminarHora", new { @id = hora.Id })</div>
                    </td>
                </tr>
            }

        <tbody>
        </tbody>
    </table><hr />
    <div class="Boton">
@Html.ActionLink("Agregar Hora", "AgregarHora", "Pacientes")</div>
</div>